package com.lefu.risk.storm.generdata;

import java.util.Arrays;
import java.util.List;

import org.apache.storm.generated.GlobalStreamId;
import org.apache.storm.grouping.CustomStreamGrouping;
import org.apache.storm.task.WorkerTopologyContext;

import clojure.main;

public class MyAssignGrouping implements CustomStreamGrouping{

	private static final long serialVersionUID = 1L;
	
	private List<Integer> tasks;

	@Override
	public void prepare(WorkerTopologyContext context, GlobalStreamId stream, List<Integer> targetTasks) {
		this.tasks = targetTasks;
		System.out.println("?>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+targetTasks.size());
		for (Integer integer : targetTasks) {
			System.out.println("id==================="+integer);
		}
	}

	@Override
	public List<Integer> chooseTasks(int taskId, List<Object> values) {
		String[] strs = (String[])values.get(0);
		String substring = strs[7].substring(7, 9).trim();
		Integer integer = tasks.get(Integer.valueOf(substring)-1);
		return Arrays.asList(integer);
	}
	
	public static void main(String[] args) {
		System.out.println(Double.valueOf(0+""));
	}

}
